package ui;

import javax.swing.table.AbstractTableModel;

public class VMidiTableModel extends AbstractTableModel {

	private Resources resources = Resources.getInstance();
	
	
	
	/**
	 * Column definition.
	 * @author clementj
	 *
	 */
	class VMidiColumnDefs {
		private String header;
		private Class<?> colClass;
		private boolean editable;
		private boolean createOnly;
		
		public VMidiColumnDefs(String header, Class<?> colClass, boolean editable, boolean createOnly) {
			this.header = header;
			this.colClass = colClass;
			this.editable = editable;
			this.createOnly = createOnly;
		}
		
		public String getHeader() {
			return header;
		}
		public void setHeader(String header) {
			this.header = header;
		}
		public Class<?> getColClass() {
			return colClass;
		}
		public void setColClass(Class<?> colClass) {
			this.colClass = colClass;
		}
		public boolean isEditable() {
			return editable;
		}
		public void setEditable(boolean editable) {
			this.editable = editable;
		}
		public boolean isCreateOnly() {
			return createOnly;
		}
		public void setCreateOnly(boolean createOnly) {
			this.createOnly = createOnly;
		}
	}
	
	private final VMidiColumnDefs columnDefs[]  = {
		new VMidiColumnDefs(resources.getString("column.name"), String.class, true, true),
//		new VMidiColumnDefs(resources.getString("column.prefix"), String.class, true, true),
		new VMidiColumnDefs(resources.getString("column.type"), String.class, true, true),
		new VMidiColumnDefs(resources.getString("column.netport"), String.class, true, true),
		new VMidiColumnDefs(resources.getString("column.active"), String.class, true, false)
	};
	
	@Override
	public Class<?> getColumnClass(int columnIndex) {
		return columnDefs[columnIndex].getColClass();
	}

	@Override
	public String getColumnName(int column) {
		return columnDefs[column].getHeader();
	}

	@Override
	public boolean isCellEditable(int rowIndex, int columnIndex) {
		// TODO : warning, take care of creation mode !
		return columnDefs[columnIndex].isEditable();
	}

	@Override
	public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
		// TODO Auto-generated method stub
		super.setValueAt(aValue, rowIndex, columnIndex);
	}

	@Override
	public int getColumnCount() {
		return columnDefs.length;
	}

	@Override
	public int getRowCount() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		// TODO Auto-generated method stub
		return null;
	}

}
